/*
 * Copyright (c) 2022-2022 Huawei Technologies Co.,Ltd.
 *
 * openGauss is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *
 *           http://license.coscl.org.cn/MulanPSL2
 *
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 */

package org.opengauss.datachecker.common.entry.enums;

import lombok.Getter;

import java.util.Objects;

/**
 * ColumnKey {@value API_DESCRIPTION }
 *
 * @author ：wangchao
 * @date ：Created in 2022/5/29
 * @since ：11
 */
@Getter
public enum SliceStatus {
    /**
     * source completed
     */
    SOURCE(1, "source completed"),
    /**
     * sink completed
     */
    SINK(2, "sink completed"),
    /**
     * source and sink all completed
     */
    ALL(3, "source and sink all completed");

    private final int code;
    private String description;

    SliceStatus(int code, String description) {
        this.code = code;
        this.description = description;
    }

    /**
     * slice status enum value
     *
     * @param endpoint endpoint
     * @return endpoint enum value code
     */
    public static int codeOf(Endpoint endpoint) {
        if (Objects.equals(Endpoint.SOURCE, endpoint)) {
            return SOURCE.code;
        } else {
            return SINK.code;
        }
    }

    /**
     * ColumnKey api description
     */
    public static final String API_DESCRIPTION = "SliceStatus [SOURCE-1,SINK-2, ALL-3]";
}
